fix(claude-code): skip primary + duplicate banks in recallAdditionalBanks - #2625
Merged
Conversation
…anks The additional-banks recall loop recalled every entry with no dedup against the resolved primary, so bidirectional cross-bank setups (primary listed in recallAdditionalBanks) re-recalled the primary on every prompt — a wasted recall call plus duplicate context. Guard the loop with a seen-set seeded with the primary bank; also dedups repeated entries. Fixes #2604.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2604.
Problem
The claude-code recall hook's
recallAdditionalBanksloop recalled every entry with no dedup against the session's resolved primary bank. So a bidirectional cross-bank setup (each bank lists the other, so both must appear inrecallAdditionalBanks) re-recalled the primary on every prompt — one wasted recall call (~0.4–0.65s) per user prompt, plus duplicate context.Fix
Guard the additional-banks loop with a
seen_banksset seeded with the primarybank_id(already recalled above). This skips the primary and also de-dups repeated entries in the list.Test
Adds
test_additional_banks_skip_primary_and_duplicates— primary listed inrecallAdditionalBanksplus a duplicated extra → asserts the primary is recalled once, the extra once, 2 calls total (not 4). Fulltest_hooks.pygreen (30 passed).Thanks @hb-cam for the precise repro and the one-liner.